﻿using System.Collections;
using UnityEngine;

namespace UI
{

    public class UIForm
    {
        internal int Score { get; set; }

        public string Name { get; private set; }

        public UIFormInfo Info { get; private set; }

        public UIElement Instance { get; private set; }

        public RectTransform Rect { get; private set; }

        public bool IsDestroy
        {
            get { return Instance == null || Instance.IsDestroyed(); }
        }

        public void Open()
        {
            UISystem.Open(this);
        }
        public void Close()
        {
            UISystem.Close(this);
        }
        public void Freez()
        {
            UISystem.Freez(this);
        }

        internal UIForm(string name, UIFormInfo info, UIElement instance)
        {
            this.Name = name;
            Instance = instance;
            Rect = instance.GetComponent<RectTransform>();
            Info = info;
        }

        public void ToTop()
        {
            Rect.SetAsLastSibling();
        }
    }
}